﻿using System;

namespace zijian666.Converts;
internal class MappingAction<TSource, TTarget> : IMappingAction
{
    private readonly Action<TSource, TTarget> _map;

    public MappingAction(Action<TSource, TTarget> map) => _map = map ?? throw new ArgumentNullException(nameof(map));

    public void Map(object source, object target)
    {
        if (source is TSource s && target is TTarget t)
        {
            _map(s, t);
        }
    }
}
